package com.csht.service.Impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.csht.mapper.CshtUserMapper;
import com.csht.model.City;
import com.csht.model.Province;
import com.csht.model.School;
import com.csht.service.IndexService;
import com.csht.service.MyService;

/**
 * 用户修改我的资料service
 * @author chenhuiyan
 *
 */
@Service
public class MyServiceImpl implements MyService {
	
	@Autowired
	private CshtUserMapper cshtUserMapper;
	
	@Autowired
	private IndexService indexService;

	/**
	 * 根据用户id修改头像
	 */
	@Override
	public void updateUserHeadById(Map<String, String> fileNameAndUserId) throws Exception {
		cshtUserMapper.updateUserHeadById(fileNameAndUserId);
	}

	/**
	 * 根据用户id修改用户名
	 */
	@Override
	public void updateUsernameById(Map<String, String> userIdAndUsername) throws Exception {
		cshtUserMapper.updateUsernameById(userIdAndUsername);
	}

	/**
	 * 根据用户id修改密码
	 */
	@Override
	public void updateUserPasswordById(Map<String, String> userIdAndUserPassword) throws Exception {
		cshtUserMapper.updateUserPasswordById(userIdAndUserPassword);
	}

	/**
	 * 获取省份
	 */
	@Override
	public List<Province> toUpdategetAllProvice(String provinceUrl) throws Exception {
		List<Province> provincelist = indexService.getAllProvince(provinceUrl);
		return provincelist;
	}
	
	/**
	 * 根据省ID获取城市
	 */
	@Override
	public List<City> toUpdategetAllCity(String cityUrl, Integer provinceId) throws Exception{
		List<City> cityList = indexService.getAllCityByProvinceId(cityUrl, provinceId);
		return cityList;
	}

	/**
	 * 根据学校ID获取学校
	 */
	@Override
	public List<School> toUpdategetAllSchool(String schoolUrl, String cityName) throws Exception {
		List<School> schoolList = indexService.getAllSchoolByCityName(schoolUrl, cityName);
		return schoolList;
	}

	/**
	 * 根据用户id修改地址
	 */
	@Override
	public void updateUserAddressById(Map<String, String> userIdAndAddress) throws Exception {
		cshtUserMapper.updateUserAddressById(userIdAndAddress);
	}

	/**
	 * 根据用户id修改用户性别
	 */
	@Override
	public void updateUserGenderById(Map<String, String> userIdAndGender) throws Exception {
		cshtUserMapper.updateUserGenderById(userIdAndGender);
	}

	/**
	 * 根据用户id修改QQ号
	 */
	@Override
	public void updateUserqqById(Map<String, String> userIdAnduserqq) throws Exception {
		cshtUserMapper.updateUserqqById(userIdAnduserqq);
	}

	/**
	 * 根据用户id修改微信号
	 */
	@Override
	public void updateUserWechatById(Map<String, String> userIdAndUserWechat) throws Exception {
		cshtUserMapper.updateUserWechatById(userIdAndUserWechat);
	}

}
